<template>
  <z-modal
    :title="title"
    destroyOnClose
    width="600px"
    :visible="visible"
    :fullscreen.sync="fullscreen"
    :switchFullscreen="switchFullscreen"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-spin :spinning="confirmLoading">
      <a-form-model layout="horizontal" labelAlign="right" ref="ruleForm" :label-col="labelCol" :wrapper-col="wrapperCol" :model="form" :rules="validatorRules">
        <a-row>
          <a-col :span="24" >
            <a-form-model-item label="文件编码">
              <a-input placeholder="请输入文件编码" v-model.trim="form.code"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="文件名称">
              <a-input placeholder="请输入文件名称" v-model.trim="form.name"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="文件">
              <ZUpload />
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="文件大小">
              <a-input disabled v-model.trim="form.size"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24" >
            <a-form-model-item label="创建时间">
              <a-date-picker disabled class="!w-full" v-model="form.createdTime"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-spin>
  </z-modal>
</template>

<script>
import ModalFormMixin from '@/mixins/ModalFormMixin'
import ZDictSelectTag from '@/components/dict/ZDictSelectTag'
import ZSelectMultiUser from '@/components/zzbiz/ZSelectMultiUser'
import ZSelectDept from '@/components/zzbiz/ZSelectDept'
import ZUpload from '@/components/zz/ZUpload'
import moment from 'moment'
export default {
  name: 'WarehouseModal',
  components: {
    ZDictSelectTag,
    ZSelectMultiUser,
    ZSelectDept,
    ZUpload
  },
  mixins: [ModalFormMixin],
  data() {
    return {
      validatorRules: {
        whName: [{ required: true, message: '请输入仓库名称' }],
        whType: [{ required: true, message: '请选择仓库属性' }]
      },
      url: {
        add: '/erp/inventory/wh/add',
        edit: '/erp/inventory/wh/edit'
      }
    }
  },
  methods: {
    addAfter() {
      this.$set(this.form, 'createdTime', moment().format('YYYY-MM-DD HH:mm:ss'))
    },
    submitAfter(res) {
      this.$message.success('保存成功')
      this.$emit('ok')
      if (this.editType === 'add') {
        this.editType = 'edit'
        this.form.whCode = res.result.whCode
        this.disableSubmit = true
      } else {
        this.close()
      }
    }
  }
}
</script>

